/**
 * @(#)EmailSmtpAuth.java 2010-2-22
 *   
 * Copyright  (c) 2009-2010 Wilmar IT Service,  Inc.   
 * All  rights  reserved.   
 * TODO
 */

package com.wilmar.process.entity;

import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;

import com.wilmar.process.system.ProcessSystem;

/**
 * @author Administrator Email:makubexnet@gmail.com
 * @version 1.0.0
 */
public class EmailSmtpAuth extends Authenticator {
	/**
	 * 完整构造函数
	 * 
	 * @param user
	 *            用户名
	 * @param password
	 *            密码
	 */
	public EmailSmtpAuth(String user, String password) {
		super();
		this.user = user;
		this.password = password;
	}

	private String user;
	private String password;

	/**
	 * @see javax.mail.Authenticator#getPasswordAuthentication()
	 */

	protected PasswordAuthentication getPasswordAuthentication() {
		return new PasswordAuthentication(user, password);
	}

	/**
	 * 默认构造函数
	 */
	public EmailSmtpAuth() {
		if (this.user == null)
			this.user = ProcessSystem.getEmailServer().getUser();
		if (this.password == null)
			this.password = ProcessSystem.getEmailServer().getPassword();
	}

	/**
	 * @return the user
	 */
	public String getUser() {
		return user;
	}

	/**
	 * @param user
	 *            the user to set
	 */
	public void setUser(String user) {
		this.user = user;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password
	 *            the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}
}
